// 图标分类数据
export interface IconCategory {
  key: string;
  name: string;
  icons: string[];
}

export const iconCategories: IconCategory[] = [
  { key: 'all', name: '全部图标', icons: [] },
  { key: 'basic', name: '基础操作', icons: ['Search', 'Edit', 'Delete', 'Add', 'Save', 'Close', 'Refresh', 'Download', 'Upload', 'ZoomIn', 'ZoomOut'] },
  { key: 'direction', name: '方向指示', icons: ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'DoubleLeft', 'DoubleRight', 'DoubleUp', 'DoubleDown', 'TurnLeft', 'TurnRight'] },
  { key: 'data', name: '数据展示', icons: ['Table', 'PieChart', 'BarChart', 'LineChart', 'Histogram', 'TrendChart', 'RadarChart', 'Map', 'Database', 'Percent'] },
  { key: 'user', name: '用户相关', icons: ['User', 'Avatar', 'UserFilled', 'UserPlus', 'UserMinus', 'UserSettings', 'Lock', 'Unlock', 'Key', 'Bell'] },
  { key: 'file', name: '文件管理', icons: ['Folder', 'FolderOpen', 'File', 'FileText', 'Document', 'Picture', 'Video', 'Music', 'PDF', 'Zip'] },
  { key: 'system', name: '系统设置', icons: ['Setting', 'Tools', 'Help', 'Info', 'Warning', 'Error', 'Success', 'Question', 'Flag', 'Bell'] },
  { key: 'other', name: '其他图标', icons: [] }
];

// 自动分配未分类图标到"其他图标"分类
export const assignUncategorizedIcons = (allIcons: string[]): IconCategory[] => {
  const categorizedIcons = new Set<string>();
  const newCategories = [...iconCategories];

  // 收集所有已分类图标
  newCategories.forEach(category => {
    if (category.key !== 'all' && category.key !== 'other') {
      category.icons.forEach(icon => categorizedIcons.add(icon));
    }
  });

  // 找出未分类图标
  const otherCategory = newCategories.find(c => c.key === 'other');
  if (otherCategory) {
    otherCategory.icons = allIcons.filter(icon => !categorizedIcons.has(icon));
  }

  // 更新"全部图标"分类
  const allCategory = newCategories.find(c => c.key === 'all');
  if (allCategory) {
    allCategory.icons = allIcons;
  }

  return newCategories;
};